<%--
 *  File:   safestockmanage.jsp
 *  Desc:	the Lend slip summary page
 *
 *  Date		  Author		  Changes
 *  2011-10-18	  KevinFan		  Created
 *
 *  Copyright (C) 2000 - 2012 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%
  //init param
  String privilegeCode = "10217,10908";
  String strModuleName = "PCM";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc" %>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/OvalLocationDefault.inc" %>
<%@ include file="/rpt/ReportURL.inc" %>
<html>
<head>
<title>HospitalSafeStock</title>
<PageFlow:CheckPageFlow pageName="p_zylsafestocksummary"/>
<%
   Vector summary = (Vector)pageContext.getAttribute("totalsummary");
   if(summary == null)summary = new Vector();
   String flag = (String)pageContext.getAttribute("flag");
   if(flag==null)flag="";
%>
<%@ include file="/inc/CatchError.inc" %>
<%@ include file="/inc/SumDiv.inc" %>



<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/Calendar.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/FuncLib.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/opal2/mootools.js"></script>
<%@ include file="/inc/NewCalendar.inc" %>
<script language="JavaScript">
	function page_summary(actionvalue,orderbyname)
	{
	  var editform = summaryPrepare(cform,actionvalue,orderbyname);
	  if(!editform) return;
	  editform.action = "SafeStockManage.jsp?<%= OvalTools.randomURL() %>";
	  editform.target = "_self";
	  isRunning = true;
	  editform.submit();
	}
	function page_submit(name)
	{ 
	  document.cform.portname.value= name;
	  document.cform.actionname.value="submit";
	  document.cform.target="_self";
	  isRunning = true;
	  document.cform.submit();
	}

    function editMode(obj,index,name,id) {
        if ($(name + index) == null) {
            var c = Trim(obj.innerText);
            var t = new Element('input', {
                'type':'text',
                'value':c,
                'styles':{
                        'width':'75px'
                         },
                'id':name + index,
                'name':name,
                'events':{
                    'blur':function() {
                        saveData(this,id,c);
                    },
                    'keydown':function() {
                        if (event.keyCode == 13) {
                            saveData(this,id,c);
                        }
                    }
                }
            });
           
            obj.innerHTML = '';
            t.inject(obj);
            selectText(t);
        }
    }
    
    function saveData(obj,id,c) {
        var p = obj.parentNode;
        if(Trim(obj.value) == ""){
          // alert("不能为空！");
           p.innerHTML =  "&nbsp;"+c;
           return;
        }
        if(!isNumeric(Trim(obj.value))){
           alert("数字格式不对！");
           p.innerHTML =  "&nbsp;"+c;
           return;
        }
        if((obj.value)<0){
           alert("数量不能为负！");
           p.innerHTML =  "&nbsp;"+c;
           return;
        }
        
        if(parseFloat(obj.value) == parseFloat(c)){
           p.innerHTML = obj.value;
		   return;
        }
        p.innerHTML = obj.value;
        var req = new Request({
            'url':'<%=contextPath%>/Dispatcher',
            'method':'get',
            'data':'pagename=p_zylsafestocksummary&actionname=ajax&columnname=' + obj.name + '&columnvalue='+ encodeURI(obj.value) + '&safestockid=' + id
        });
        req.send(); 
    }

    //选中文本框中的字符

    function selectText(obj) {
        var range = obj.createTextRange();
        range.moveStart("character", 0);
        range.select();
    }
    
    function page_csv(){
    	userid = document.cform.userid.value;
    	serorgcode = document.cform.serorgcode.value;
    	serorgname = document.cform.serorgname.value;
    	createdate1 = document.cform.createdate1.value;
    	createdate2 = document.cform.createdate2.value;
    	serprodcode = document.cform.serprodcode.value;
    	serprodname = document.cform.serprodname.value;
    	serstatus = document.cform.serstatus.value;  
	window.open("<%= reportURL %>/csv?__report=/ovalreport/hospitalcsv.txt&serorgcode="+escape(encodeURI(serorgcode))+"&serorgname="+escape(encodeURI(serorgname))+"&createdate1="+escape(encodeURI(createdate1))+"&createdate2="+escape(encodeURI(createdate2))+"&serprodcode="+escape(encodeURI(serprodcode))+"&serprodname="+escape(encodeURI(serprodname))+"&serstatus="+serstatus+"&useridstr="+userid); 
    }	

</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" >
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
<input type="hidden" name="pagename" value="p_zylsafestocksummary">
<input type="hidden" name="actionname">
<input type="hidden" name="portname"> 
<custom:hidden property="businesstype"/>
<custom:hidden name="userinfo" property="userid"/>
<custom:hidden property="flag"/>
<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" onkeydown="if(event.keyCode==13) page_summary('search');">
        <tr>
	        <td class="td_right" width="6%"><%= "医院编码" + label.getLabelName("L_Colon") %></td>
            <td class="td_left" width="7%">
                <custom:text property="serorgcode" size="15" />
			</td>
			<td class="td_right" width="7%"><%= "医院名称" + label.getLabelName("L_Colon") %></td>
            <td class="td_left" width="7%">
                <custom:text property="serorgname" size="15" />
			</td>
			<td class="td_right" width="7%"><%= "创建日期" +  label.getLabelName("L_Colon") %></td>
			<td class="td_left" width="*">
				<custom:text property="createdate1" size="10" />
				<a onclick="javascript:c.show(this,'cform.createdate1','yyyy-MM-dd')"><input type=button class="button3" value="*"></a>--
				<custom:text property="createdate2" size="10" />
				<a onclick="javascript:c.show(this,'cform.createdate2','yyyy-MM-dd')"><input type=button class="button3" value="*"></a>
			</td>
        </tr>
		<tr>
			<td class="td_right"><%= "产品编码" + label.getLabelName("L_Colon") %></td>
            <td class="td_left">
                <custom:text property="serprodcode" size="15" />
			</td>
			<td class="td_right"><%= "产品名称" + label.getLabelName("L_Colon") %></td>
            <td class="td_left">
                <custom:text property="serprodname" size="15" />
			</td>
			<td class="td_right"><%= "状态" + label.getLabelName("L_Colon") %></td>
            <td class="td_left">
				<custom:selectdic dictType="Status" property="serstatus" defaultValue="------" defaultValueCost="" valueCriteria="28,41"/>
				&nbsp;&nbsp;
				<a href="javascript:page_summary('search')"><img src="/oval/images/cn/go.gif" border="0" ></a>
			</td>
			
        </tr>
      </table>
    </td>
  </tr>
  <tr>
	<td colspan="2">
      <div style="width:100%;height=400;overflow=auto;">
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr class="deepblue-left"> 
          <%if(!(flag).equals("view")){%>
		  <td width="1%" class="title_center">&nbsp;</td>
		  <%}%>
          <td class="title_center"><a href="javascript:page_summary('orderby','orgcode')"><%= label.getLabelName("L_HospitalCode") %></a></td>
          <td class="title_center"><a href="javascript:page_summary('orderby','orgname')"><%= label.getLabelName("L_HospitalName") %></a></td>
          <td class="title_center"><a href="javascript:page_summary('orderby','prodcode')"><%= label.getLabelName("L_Prodcode1") %></a></td>
          <td class="title_center"><a href="javascript:page_summary('orderby','prodname')"><%= label.getLabelName("L_ProdName") %></a></td>
          <td class="title_center"><a href="javascript:page_summary('orderby','datelastupdate')"><%= label.getLabelName("L_TurnoverTime") %></a></td>
          <td class="title_center"><a href="javascript:page_summary('orderby','qty')"><%= "安全库存数量" %></a></td>
          <td class="title_center"><a href="javascript:page_summary('orderby','amount01')"><%= label.getLabelName("L_Status") %></a></td>
        </tr> 
        <tbody> 
          <%
            int i=0;
            String strChecked = "";
            String strClassType = "none";
            boolean bHasChecked = false;
          %>
          <logic:iterate id="onerow" collection="<%= summary %>">
          <%
            if(i%2 == 1){
              strClassType = "td-listrom";
            }else{
              strClassType = "none";
            }
            if(!bHasChecked){
              bHasChecked = true;
              strChecked = "Checked";
            }else{
              strChecked = "";
            }
            i++;
          %>
          <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'" onClick="radiotrue('radio<%=JspHelper.filterNull( i )%>')" class="<%=JspHelper.filterNull( strClassType )%>">
            <%if(!(flag).equals("view")){%>
			<td>
              <input <%=JspHelper.filterNull( strChecked )%> id="radio<%=JspHelper.filterNull(i)%>" name="radiorow" type="radio" class="normalradio">
            </td>
			<%}%>
            <td><custom:write name="onerow" property="orgcode" nbsp="true"/></td>
            <td><custom:write name="onerow" property="orgname" nbsp="true"/></td>
            <td><custom:write name="onerow" property="prodcode" nbsp="true"/></td>
            <td><custom:write name="onerow" property="prodname" nbsp="true"/></td>
            <td><custom:write name="onerow" property="datelastupdate" nbsp="true"/></td>
			 <%if(privilegeSet != null && privilegeSet.contains("MB-AQKC03")){%>
            <td onclick="editMode(this,'<%=i%>','qty','<custom:write name="onerow" property="safestockid"/>');"><custom:write name="onerow" property="qty" nbsp="true"/></td>
			<%}else{%>
            <td><custom:write name="onerow" property="qty" nbsp="true"/></td>
			<%}%>
            <td><custom:write name="onerow" property="status" nbsp="true" dictType="Status"/></td>
          </tr>
          
          </logic:iterate>
          
        </tbody> 
        <tfoot> 
	        <tr> 
	          <td colspan="31"> 
	          <%@ include file="/inc/SummaryAction.inc" %>
	          </td>
	        </tr>
	        </tfoot> 
	         
      </table>
     
	  </div>
    </td>
  </tr>
  <tr> 
  	<table width="100%" cellspacing="0" cellpadding="0" border="0">
  		<tr>
  			<td class="td_center" colspan="100">
  			<a onclick="page_csv();"><custom:button type="1" value="导出CSV" imgsrc="Modify.gif" border="0" style="width:100" privilegeCode="MB-AQKC01"/></a>&nbsp;&nbsp;
			</td>
  		</tr>
  	</table>
  	</tr>
  <%if(!(flag).equals("view")){%>
  <tr>
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td class="td_center" colspan="100">
				<a onClick="page_submit('zylautocountsafestock')"><custom:button type="1" label="L_AutoCount" imgsrc="back.gif" border="0" style="width:80" privilegeCode="MB-AQKC02"/></a>
			</td>
		</tr>
	</table>
  </tr>
  <%}%>
  
 </table>
 </form>
</body>
</html>